<?php

declare(strict_types=1);

namespace app\controller\admin;

use app\model\admin\ApplyMoneySet;
use app\model\admin\BalanceLog;
use app\model\admin\CateModel;
use app\model\admin\MiniApply;
use app\model\admin\MiniBalanceLog;
use app\model\admin\MiniUser;
use app\model\admin\Pact;
use app\model\admin\SysMember;
use app\model\admin\SysUser;
use app\service\MemberService;
use app\service\SysUserService;
use think\facade\Db;
use think\facade\Validate;
use think\Request;

class BalanceLogController extends AdminBaseController
{
    public function getBalanceLog(Request $request)
    {
        $params = $request->param();
        $user_type = $params['user_type'] ?? 'mini';
        if ($user_type == 'mini') {
            $params['is_operator'] = 0;
            // ->with(['order:order_sn,money', 'user:id,real_name,type', 'from_user:id,real_name'])
            $list = BalanceLog::scope('where', $params)
                ->with(['user', 'order', 'fromUser'])->order('id', 'desc')
                ->paginate([
                    'list_rows' => $this->limit,
                    'page' => $this->page,
                    'var_page' => $this->pageVar
                ]);
            return successPage($list);
        } else {
            $params['is_operator'] = 1;
            $list = BalanceLog::scope('where', $params)
                ->with(['sysUser', 'order', 'fromUser'])->order('id', 'desc')
                ->paginate([
                    'list_rows' => $this->limit,
                    'page' => $this->page,
                    'var_page' => $this->pageVar
                ]);
            return successPage($list);
        }
    }
}
